package com.mes.production.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.mes.common.core.utils.poi.ExcelUtil;
import com.mes.common.core.web.controller.BaseController;
import com.mes.common.core.web.domain.AjaxResult;
import com.mes.common.core.web.page.TableDataInfo;
import com.mes.common.log.annotation.Log;
import com.mes.common.log.enums.BusinessType;
import com.mes.common.security.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.mes.production.domain.ProductionProcess;
import com.mes.production.service.IProductionProcessService;

/**
 * 工序管理Controller
 * 
 * @author itflash
 * @date 2025-02-27
 */
@RestController
@RequestMapping("/production/productionProcess")
public class ProductionProcessController extends BaseController
{
    @Autowired
    private IProductionProcessService productionProcessService;

    /**
     * 查询工序管理列表
     */
    @RequiresPermissions("production:productionProcess:list")
    @GetMapping("/list")
    public TableDataInfo list(ProductionProcess productionProcess)
    {
        startPage();
        List<ProductionProcess> list = productionProcessService.selectProductionProcessList(productionProcess);
        return getDataTable(list);
    }

    /**
     * 导出工序管理列表
     */
    @RequiresPermissions("production:productionProcess:export")
    @Log(title = "工序管理", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ProductionProcess productionProcess)
    {
        List<ProductionProcess> list = productionProcessService.selectProductionProcessList(productionProcess);
        ExcelUtil<ProductionProcess> util = new ExcelUtil<ProductionProcess>(ProductionProcess.class);
        util.exportExcel(response, list, "工序管理数据");
    }

    /**
     * 获取工序管理详细信息
     */
    @RequiresPermissions("production:productionProcess:query")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(productionProcessService.selectProductionProcessById(id));
    }

    /**
     * 新增工序管理
     */
    @RequiresPermissions("production:productionProcess:add")
    @Log(title = "工序管理", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ProductionProcess productionProcess)
    {
        return toAjax(productionProcessService.insertProductionProcess(productionProcess));
    }

    /**
     * 修改工序管理
     */
    @RequiresPermissions("production:productionProcess:edit")
    @Log(title = "工序管理", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ProductionProcess productionProcess)
    {
        return toAjax(productionProcessService.updateProductionProcess(productionProcess));
    }

    /**
     * 删除工序管理
     */
    @RequiresPermissions("production:productionProcess:remove")
    @Log(title = "工序管理", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(productionProcessService.deleteProductionProcessByIds(ids));
    }
}
